package com.cq.hd.member.controller;

import com.cq.hd.common.pagination.Page;
import com.cq.hd.common.response.Result;
import com.cq.hd.common.response.ResultGenerator;
import com.cq.hd.member.api.TbBusinessEnterApplyApi;
import com.cq.hd.member.api.dto.*;
import com.cq.hd.member.api.vo.BusinessEnterApplyDetailVo;
import com.cq.hd.member.api.vo.BusinessEnterApplyPageVo;

import com.cq.hd.member.api.vo.BusinessEnterApplyVo;
import com.cq.hd.member.service.TbBusinessEnterApplyService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 商家入驻申请记录表 前端控制器
 * </p>
 *
 * @author mYunYu
 * @since 2023-11-21
 */
@RestController
public class TbBusinessEnterApplyController implements TbBusinessEnterApplyApi {

    @Autowired
    private TbBusinessEnterApplyService businessEnterApplyService;

    @ApiOperation(value = "商家入驻申请列表")
    @ApiImplicitParam(name = "businessEnterApplyPageDto", value = "实体", required = true, paramType = "query", dataType = "BusinessEnterApplyPageDto")
    @ApiResponse(response = BusinessEnterApplyPageVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<Page<BusinessEnterApplyPageVo>> pageBusinessEnterApply(BusinessEnterApplyPageDto businessEnterApplyPageDto) {
        return ResultGenerator.success(businessEnterApplyService.pageBusinessEnterApply(businessEnterApplyPageDto));
    }

    @ApiOperation(value = "商家入驻申请详情")
    @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "query", dataType = "Long")
    @ApiResponse(response = BusinessEnterApplyPageVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<BusinessEnterApplyPageVo> details(Long id) {
        return ResultGenerator.success(businessEnterApplyService.details(id));
    }

    @ApiOperation(value = "商家入驻申请审核")
    @ApiImplicitParam(name = "businessEnterAuditDto", value = "实体", required = true, paramType = "body", dataType = "BusinessEnterAuditDto")
    @Override
    public Result<Boolean> audit(@RequestBody BusinessEnterAuditDto businessEnterAuditDto) {
        return ResultGenerator.success(businessEnterApplyService.audit(businessEnterAuditDto));
    }

    @ApiOperation(value = "商家入驻申请")
    @ApiImplicitParam(name = "businessEnterApplyDto", value = "实体", required = true, paramType = "body", dataType = "BusinessEnterApplyDto")
    @Override
    public Result<Boolean> apply(@RequestBody BusinessEnterApplyDto businessEnterApplyDto) {
        return ResultGenerator.success(businessEnterApplyService.apply(businessEnterApplyDto));
    }

    @ApiOperation(value = "更新商家入驻信息")
    @ApiImplicitParam(name = "businessEnterApplyUpdateDto", value = "实体", required = true, paramType = "body", dataType = "BusinessEnterApplyUpdateDto")
    @Override
    public Result<Boolean> updateBusinessEnterApplyById(@RequestBody BusinessEnterApplyUpdateDto businessEnterApplyUpdateDto) {
        return ResultGenerator.success(businessEnterApplyService.updateBusinessEnterApplyById(businessEnterApplyUpdateDto));
    }

    @ApiOperation(value = "商家入驻成功处理商家账号和绑定处理")
    @Override
    public Result<Boolean> enterSuccess(Long id) {
        return ResultGenerator.success(businessEnterApplyService.enterSuccess(id));
    }

    @ApiOperation(value = "手动开通商户业务")
    @ApiImplicitParam(name = "merchantOpenDto", value = "实体", paramType = "body", dataType = "MerchantOpenDto")
    @Override
    public Result<Boolean> merchantOpen(@RequestBody MerchantOpenDto merchantOpenDto) {
        return ResultGenerator.success(businessEnterApplyService.merchantOpen(merchantOpenDto));
    }

    @ApiOperation(value = "手动开通子账号")
    @ApiImplicitParam(name = "merchantSubAcctOpenDto", value = "实体", paramType = "body", dataType = "MerchantSubAcctOpenDto")
    @Override
    public Result<Boolean> merchantSubAcctOpen(@RequestBody MerchantSubAcctOpenDto merchantSubAcctOpenDto) {
        return ResultGenerator.success(businessEnterApplyService.merchantSubAcctOpen(merchantSubAcctOpenDto));
    }

    @ApiOperation(value = "根据用户id获取商家入驻数据")
    @ApiImplicitParam(name = "userId", value = "实体", paramType = "query", dataType = "Long")
    @ApiResponse(response = BusinessEnterApplyVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<BusinessEnterApplyVo> getEnterInfoByUserId(Long userId) {
        return ResultGenerator.success(businessEnterApplyService.getEnterInfoByUserId(userId));
    }

    @ApiOperation(value = "根据条件获取商家入驻列表")
    @Override
    public Result<List<BusinessEnterApplyPageVo>> listByDto(@RequestBody BusinessEnterApplyQueryDto businessEnterApplyQueryDto) {
        return ResultGenerator.success(businessEnterApplyService.listByDto(businessEnterApplyQueryDto));
    }

    @ApiOperation(value = "定时检测商家是否签约成功和微信实名成功")
    @Override
    public Result<Boolean> scanBusinessEnter() {
        return ResultGenerator.success(businessEnterApplyService.scanBusinessEnter());
    }

    @Override
    public Result<BusinessEnterApplyDetailVo> getSuccessEnterInfoByOpenid(String openid) {
        return ResultGenerator.success(businessEnterApplyService.getSuccessEnterInfoByOpenid(openid));
    }

    @Override
    public Result<Boolean> validSettleCode(String settleCode) {
        return ResultGenerator.success(businessEnterApplyService.validSettleCode(settleCode));
    }
}
